package com.tangula.web.kashine.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.tangula.orm.jpa.AbstractJpaEntity;

@Entity
@Table(name="t_send_money_sche")
public class SendMoneyScheduleEntity extends AbstractJpaEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7824881641728394971L;
	
	public static final String TYPE_TEACHRE_2_STUDENT="t2s";
	public static final String TYPE_STUDENT_2_TEACHRE="s2t";
	

	public static final int TYPE_EXEC_RESULT_NOT_EXEC=0;
	public static final int TYPE_EXEC_RESULT_FINISH=1;
	
	@Column(name="send_type", length=10)
	private String type;

	@Column(name="sender_id", length=36)
	private String senderId;

	@Column(name="receiver_id", length=36)
	private String receiverId;

	@Column(name="send_date", length=20)
	private String sendDate;

	@Column(name="amount", length=20)
	private String amount;
	
	@Column(name="exec_start_tm")
	private long execStartTm=0;

	@Column(name="exec_finish_tm")
	private long execFinishTm=0;
	
	/**
	 * 0 - not execute
	 * 1 - execute success
	 * other - wrong
	 */
	@Column(name="exec_result")
	private int execResult=0;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSenderId() {
		return senderId;
	}

	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}

	public String getReceiverId() {
		return receiverId;
	}

	public void setReceiverId(String receiverId) {
		this.receiverId = receiverId;
	}

	public String getSendDate() {
		return sendDate;
	}

	public void setSendDate(String sendDate) {
		this.sendDate = sendDate;
	}

	public long getExecStartTm() {
		return execStartTm;
	}

	public void setExecStartTm(long execStartTm) {
		this.execStartTm = execStartTm;
	}

	public long getExecFinishTm() {
		return execFinishTm;
	}

	public void setExecFinishTm(long execFinishTm) {
		this.execFinishTm = execFinishTm;
	}

	public int getExecResult() {
		return execResult;
	}

	public void setExecResult(int execResult) {
		this.execResult = execResult;
	}
	
	

	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	public static SendMoneyScheduleEntity fromTeacherSendMoneyForm(SendMoneyForm send) {
		SendMoneyScheduleEntity res = new SendMoneyScheduleEntity();
		res.setReceiverId(send.getStudentId());
		res.setSenderId(send.getTeacherId());
		res.setSendDate(send.getSendTm());
		res.setAmount(send.getAmount());
		res.setType(TYPE_TEACHRE_2_STUDENT);
		return res;
	}
	
	
	

}
